package demo;


import java.util.HashMap;
import java.util.Map;

public class Demo1 {
    public static void main(String[] args) {
        int[] nums = new int[1000];
        int ret = 0;
        HashMap<Integer, Integer> hash = new HashMap<>();
        for(int i = 0; i < nums.length; i++) {
            if(!hash.containsKey(nums[i])) {
                hash.put(nums[i], i);
            } else {
                hash.put(nums[i], hash.get(nums[i]) + 1);
            }
        }
        for(Map.Entry<Integer, Integer> entry : hash.entrySet()) {
            if(entry.getValue() == 2) {
                ret = entry.getKey();
            }
        }
        System.out.println(ret);
    }
}
